home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 4 / Apprentice-Release4.iso / Source Code / Libraries / BSP Tree 1.2 / Sources / Graphics / include / polygon_3d.h < prev    next >
Encoding:
Text File  |  1995-04-05  |  3.5 KB  |  59 lines  |  [TEXT/MMCC]

  1. //------------------------------------------------------------------------------
  2. //    File:                    polygon.h
  3. //    Date:                    8/29/94
  4. //    Author:                Bretton Wade
  5. //
  6. //    Description:    this file contains the class definition for a polygon.
  7. //
  8. //------------------------------------------------------------------------------
  9.  
  10. #include "plane_3d.h"
  11.  
  12. #ifndef    POLYGON
  13. #define    POLYGON
  14.  
  15. //------------------------------------------------------------------------------
  16. //    classes
  17. //------------------------------------------------------------------------------
  18. class    polygon : public object_3d                                                                                                //    3 dimensional polygon class
  19. {                                                                                                                                                                //    begin polygon class definition
  20.     private:                                                                                                                                            //    members internal to this class only
  21.     protected:                                                                                                                                        //    members internal to this class hierarchy
  22.                 plane_3d    plane;                                                                                                                //    plane_3d equation for the polygon
  23.                 uchar            count;                                                                                                                //    number of points in the polygon
  24.                 point_3d    *points;                                                                                                            //    the array of points that compose the polygon
  25.     public:                                                                                                                                                //    members available externally
  26.                 polygon (point_3d *buffer, uchar count, va_list pts);                                        //    normal constructor
  27.                 polygon (point_3d *buffer, uchar count);                                                                //    normal constructor
  28. virtual    ~polygon (void);                                                                                                                //    destructor
  29.                 uchar            Count (void) const;                                                                                        //    return the number of points in the polygon
  30. const        point_3d    &Vertex (int i) const;                                                                                //    return the ith point_3d of the polygon
  31. const        plane_3d    &Plane (void) const;                                                                                    //    return a reference to the plane_3d of the polygon
  32.                 vector_3d    Normal (void) const;                                                                                    //    compute the plane_3d normal vector_3d Newell's method
  33.                 bool            Contains (const point_3d &pt) const;                                                    //    test the point_3d to see if it is inside the polygon (crossings method)
  34.                 real            Area (void) const;                                                                                        //    compute the area of the polygon
  35.                 void            Invert (void);                                                                                                //    completely reverse the orientation of the polygon
  36. virtual    real            RayIntersection (const ray &r) const;                                                    //    return the distance along the ray at which the intersection occurs
  37. };                                                                                                                                                            //    end polygon class definition
  38.  
  39. //------------------------------------------------------------------------------
  40. //    inlines
  41. //------------------------------------------------------------------------------
  42. inline    uchar    polygon::Count (void) const                                                                                //    return the number of points in the polygon
  43. {                                                                                                                                                                //    begin
  44.     return count;                                                                                                                                    //    return the count
  45. }                                                                                                                                                                //    end
  46.  
  47. inline    const    point_3d    &polygon::Vertex (int i) const                                                    //    return the ith point_3d of the polygon
  48. {                                                                                                                                                                //    begin
  49.     return points[i];                                                                                                                            //    return the point_3d
  50. }                                                                                                                                                                //    end
  51.  
  52. inline    const    plane_3d    &polygon::Plane (void) const                                                        //    return a reference to the plane_3d of the polygon
  53. {                                                                                                                                                                //    begin
  54.     return plane;                                                                                                                                    //    return the plane_3d associated with the polygon
  55. }                                                                                                                                                                //    end
  56.  
  57. //------------------------------------------------------------------------------
  58.  
  59. #endif    //POLYGON